<? 
    session_start();
	include ("../core/conn.php");
	$db = get_conn();
	//url ="ajax_comps/directions.php?id="+id_orden+"&d=n";
	
	$id_orden= $_GET['id'];
	$d= $_GET['d'];	
	if($d=='n'){
		$operador = ">";	
	}else{
		$operador = "<";	 
	}
	$sql ="select id_orden from ordenes  where id_orden ".$operador.$id_orden." and estado='C' order by  id_orden asc limit 0,1 ";
	//echo $sql;
	$result = mysql_query($sql);	
	if($result){
		if(mysql_num_rows($result) >0){
			$row = mysql_fetch_array($result);
			$id_orden = $row['id_orden'];
			echo "<input type='hidden' name='directions_id' value='".$id_orden."' id='directions_id'  />";
		}else{
			echo "<input type='hidden' name='directions_id' value='".$_GET['id']."' id='directions_id'  />";
		}
	}else{
		error_handling(__FUNCTION__.$sql,mysql_error());
	}	
?>
